package com.showgood;

import org.armedbear.lisp.Fixnum;
import org.armedbear.lisp.Function;
import org.armedbear.lisp.Interpreter;
import org.armedbear.lisp.JavaObject;
import org.armedbear.lisp.LispObject;
import org.armedbear.lisp.Symbol;

public class Abcl {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Interpreter interpreter = Interpreter.createInstance();
		interpreter.eval("(format t \"hello world\")");
		Fixnum result = (Fixnum) interpreter.eval("(+ 1 2 3 4)");
		System.out.println(result.value);
		//interpreter.eval("(load \"functions.lisp\")");
		interpreter.eval("(defun hello (a b) (+ (jobject-lisp-value a) (jobject-lisp-value b)))");
		org.armedbear.lisp.Package defaultPackage = org.armedbear.lisp.Packages.findPackage("CL-USER");
		Symbol symHello = defaultPackage.findAccessibleSymbol("HELLO");
		Function function = (Function) symHello.getSymbolFunction();
		LispObject sum = function.execute(new JavaObject(1), new JavaObject(2));
		System.out.println(sum.intValue());
	}

}
